//
//  RSTableHeadView.m
//  SafeFoodManagerDemo
//
//  Created by bob on 2017/10/18.
//  Copyright © 2017年 bob. All rights reserved.
//

#import "RSTableHeadView.h"
#import "TB_FMDBManager.h"
@interface RSTableHeadView ()

@property(nonatomic,strong)UILabel *titleLabel;

@property(nonatomic,strong)UIButton *ClearBtn;

@end

@implementation RSTableHeadView

-(instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
    if (self=[super initWithReuseIdentifier:reuseIdentifier]) {
     
        self.titleLabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 4, SCREEN_WIDTH-30, 21)];
        
        self.titleLabel.textColor=TBColorTitle;
        
        self.titleLabel.font=[UIFont systemFontOfSize:15];
        
        self.titleLabel.textAlignment=NSTextAlignmentLeft;
        
        [self.contentView addSubview:self.titleLabel];
        
       
        self.ClearBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        
        self.ClearBtn.frame=CGRectMake(SCREEN_WIDTH-35, 4, 20, 20);
        
        [self.ClearBtn setImage:[UIImage imageNamed:@"delete"] forState:UIControlStateNormal];
        
        [self.ClearBtn addTarget:self action:@selector(ClearnAction:) forControlEvents:UIControlEventTouchUpInside];
        
        [self.contentView addSubview:self.ClearBtn];
        
        self.ClearBtn.hidden=YES;
        
        
    }
    return self;
    
}

-(void)setRtitle:(NSString *)Rtitle
{
    _Rtitle=Rtitle;

    self.titleLabel.text=Rtitle;
    
}

-(void)ClearnAction:(UIButton*)sender
{
    
    [[TB_FMDBManager shareDataBase]DeleAllHistory];
    
    _block();
    
}

-(void)setIsShowDele:(BOOL)isShowDele
{
    self.ClearBtn.hidden=!isShowDele;
    
    
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
